#include<bits/stdc++.h>

using namespace std;
char b[33];//二进制字符串表示
int main() {
    cin >> b;

    if (b[0] == '0') {//b对应的数是一个非负数
        int a = 0;
        for (int i = 1; i <= 31; i++) {
            int d = b[i] - '0';
            a = a * 2 + d;
        }
        cout << a << endl;
    } else {
        for (int i = 0; i < 32; i++)
            if (b[i] == '0')
                b[i] = '1';
            else
                b[i] = '0';
        int a = 0;
        for (int i = 1; i <= 31; i++) {
            int d = b[i] - '0';
            a = a * 2 + d;
        }
        cout << -(a + 1) << endl;
    }

    return 0;
}